//
//  MainTabBarController.m
//  LoveHappyShopping
//
//  Created by 白水非泉 on 16/6/23.
//  Copyright © 2016年 白水非泉. All rights reserved.
//

#import "MainTabBarController.h"
#import "MainNavController.h"
#import "GoodViewController.h"
#import "SortViewController.h"
#import "BetterViewController.h"
#import "TopicViewController.h"
#import "MineViewController.h"
@interface MainTabBarController ()

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    GoodViewController *goodsVC=[[GoodViewController alloc]init];
    [self addNavControllerWithController:goodsVC title:@"商品" normalImg:nil selecteImg:nil];
    SortViewController *sortVC=[[SortViewController alloc]init];
    [self addNavControllerWithController:sortVC title:@"分类" normalImg:nil selecteImg:nil];
    BetterViewController *betterVC=[[BetterViewController alloc]init];
    [self addNavControllerWithController:betterVC title:@"好货" normalImg:nil selecteImg:nil];
    TopicViewController *topicVC=[[TopicViewController alloc]init];
    [self addNavControllerWithController:topicVC title:@"专题" normalImg:nil selecteImg:nil];
    MineViewController *mineVC=[[MineViewController alloc]init];
    [self addNavControllerWithController:mineVC title:@"我的" normalImg:nil selecteImg:nil];
    self.selectedIndex=2;
    
}
+(void)initialize{
    UITabBarItem *item=[UITabBarItem appearance];
    NSDictionary *dict=@{NSForegroundColorAttributeName:color(120, 110, 100),NSFontAttributeName:[UIFont systemFontOfSize:16]};
    [item setTitleTextAttributes:dict forState:UIControlStateNormal];
}
-(void)addNavControllerWithController:(UIViewController *)controller title:(NSString *)title normalImg:(NSString *)normalImg selecteImg:(NSString *)selectedImage{
    MainNavController *nav=[[MainNavController alloc]initWithRootViewController:controller];
    nav.tabBarItem.title=title;
    UIImage *normalImage=[UIImage imageNamed:normalImg];
    nav.tabBarItem.image=normalImage;
    UIImage *selectedImg=[UIImage imageNamed:selectedImage];
    nav.tabBarItem.selectedImage=selectedImg;
    
    [self addChildViewController:nav];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
